/**
 * 
 */
package wcg;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;



/**
 * @author ikechan
 *
 */
public class JComboBoxInOptionpane extends JFrame {
	
	static final String Select = "Sports";
	String input = "";
	
	public JComboBoxInOptionpane() {
		super(Select);
		JButton button=new JButton("Add");

		ActionListener lst = new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				String[] sport = new String[] {"Cricket", "FootBall", "Tennis", "Hockey" };
				input = (String) JOptionPane.showInputDialog(JComboBoxInOptionpane.this,
						"Please select your favorite sport",Select, JOptionPane.INFORMATION_MESSAGE, 
						null, sport,"Tennis");
				JOptionPane.showMessageDialog(null,"You have selected: "+input);
			}

		};
		System.out.println(input);
		button.addActionListener(lst);
		add(button);
		pack();
		setVisible(true);

	}
	
	public static void main(String argv[]) {
		new JComboBoxInOptionpane();
	}
}
